<template>
	<view>
		<view class="change_pwd_box">
			<text>原密码</text>
			<!-- <input type="text" placeholder="请输入原密码" placeholder-class="placeholder_class" v-model="old_pwd"> -->
			<u--input type="password" placeholder="请输入原密码" border="bottom" clearable v-model="old_pwd"></u--input>
			<text>新密码</text>
			<!-- <input type="text" placeholder="请输入新密码" placeholder-class="placeholder_class" v-model="new_pwd"> -->
			<u--input type="password" placeholder="请输入新密码" border="bottom" clearable v-model="new_pwd"></u--input>
			<!-- 	<text>确认密码</text>
			<input type="text" placeholder="请再次输入新密码" v-model="new_pwds"> -->
		</view>
		<view class="order" @click="_order">确认</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				old_pwd: '',
				new_pwd: '',
				new_pwds: ''
			}
		},
		methods: {
			async _order() {
				if (this.old_pwd == '' || this.old_pwd == null) {
					uni.showToast({
						title: '请输入旧密码',
						icon: 'none',
						duration: 3000
					})
					return false
				}
				if (this.new_pwd == '' || this.new_pwd == null) {
					uni.showToast({
						title: '请输入新密码',
						icon: 'none',
						duration: 3000
					})
					return false
				}
				uni.showLoading({
					title: '加载中'
				});
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'user/updatePwd',
					data: {
						old_pwd: this.old_pwd,
						new_pwd: this.new_pwd
					},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					uni.showToast({
						title: res.msg,
						duration: 2000,
						icon: 'none',
						success() {
							setTimeout(function() {
								uni.removeStorageSync('userinfo');
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 2000)
						}
					});
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.change_pwd_box {
		padding: 30rpx;
		box-sizing: border-box;

		text {
			font-size: 28rpx;
			color: #333;
			padding-left: 10rpx;
			margin: 20rpx 0;
			display: block;
		}

		input {
			padding: 10rpx;
			border-bottom: #eeeeee 1px solid;
			font-size: 28rpx;
		}
	}

	.order {
		background-color: #1296db;
		margin: 50rpx 20rpx;
		text-align: center;
		padding: 30rpx 0;
		border-radius: 10rpx;
		color: #fff;
		transition: all 0.5s;
	}

	.order:active {
		background-color: #1296db;
	}
</style>
<style>
	.placeholder-class {
		color: #e1e1e1;
	}
</style>
<style scoped lang="scss">
	.placeholder-class {
		color: #e1e1e1;
	}
</style>